<!--
 * @Descripttion: 
 * @version: 
 * @Author: chenWeiLong
 * @Date: 2022-02-26 11:05:48
 * @LastEditors: please set LastEditors
 * @LastEditTime: 2022-02-26 11:59:03
-->

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>最简分数</title>
</head>
<body>
    <script>

        //计算最大公约数 
        /**
         * @name: 
         * @test: test font
         * @msg: 
         * @param {number} a
         * @param {number} b
         * @return {*}
         */        
        function gcd(a,b){
            var result = 1;
            for(var i = 1; i <= a && i <= b; i++ ){
                if(a%i == 0 && b%i == 0 ){
                    result = i;
                }
            }
            return result;
        }
       
        function gcd1(a,b){
            if(b == 0){
                return a;
            }
            var r = a % b;
            console.log(r);
            return gcd(b,r);
        }
      
        function gcd2(a,b){
            var temp;
            while(b != 0){
                temp = a % b;
                a = b;
                b = temp;
            }
            return a;
        }
        // 最小公倍数
        /**
         * @name: scm
         * @param {number} a
         * @param {number} b
         * @return {*}
         */        
        function scm(a,b){
            return (a*b)/gcd(a,b);
        }
        /**
         * @name: Fraction
         * @param {number} n
         * @return {string[]} arr
         */
        function Fraction(n){
            let arr = [];
            for(let i= 2; i <= n; i++){
                for(let k = 1; k < i; k++){
                    if(gcd(k,i)== 1){
                        // 1.break：跳出当前循环体，也称结束当前循环体
                        // 2.continue：跳出此次循环，继续执行下一次循环
                        arr.push(k+'/'+i)
                    }
                }
            }
            return arr;
        }
        console.log(Fraction(10));
    </script>
</body>
</html>